import { type BaseResult } from '@/types/request'
import request from '@/utils/http/request'

interface checkCode {
  checkCode: string
  checkCodeKey: string
}

export interface LoginParams {
  email: string
  nickName?: string
  password: string
  rePassword?: string
  checkCode: string
  checkCodeKey: string
}

export class UserService {
  static getCaptcha() {
    return request.post<BaseResult<checkCode>>({ url: '/account/checkCode' })
  }

  static register(params: LoginParams) {
    return request.post<BaseResult>({ url: '/account/register', params })
  }

  static login(params: LoginParams) {
    return request.post<BaseResult>({ url: '/account/login', params })
  }
}
